using Microsoft.Extensions.Hosting.WindowsServices;
using WeChatV3Pay.Core.Options;
using WeChatV3Pay.Services;


var options = new WebApplicationOptions
{
    Args = args,
    ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
};

var builder = WebApplication.CreateBuilder(options).Inject();

// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
// Add services to the container.
builder.Services.AddGrpc();
builder.Services.AddConfigurableOptions<AppInfosOptions>();
builder.Services.AddRemoteRequest();

builder.Host.UseWindowsService();

var app = builder.Build();

// Configure the HTTP request pipeline.
app.MapGrpcService<WeChatPayService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");

app.Run();
